 package uk.co.mmscomputing.util;
 
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
 
 public class JarFile extends File
 {
   private static ClassLoader cl = JarFile.class.getClassLoader();
 
   public JarFile(String paramString) throws IOException {
     super(load(paramString));
   }
 
   private static String load(String paramString) throws IOException {
     String str1 = System.getProperty("user.dir") + File.separator + paramString.replace('/', File.separatorChar);
     String str2 = new File(str1).getParent();
     if (str2 != null) new File(str2).mkdirs();
     if (new File(str1).exists()) return str1;
 
     paramString = paramString.replace(File.separatorChar, '/');
     URL localURL = cl.getResource(paramString);
     if (localURL == null) return str1;
 
     if (localURL.toString().startsWith("file:"))
       str1 = localURL.getFile();
     else if (localURL.toString().startsWith("jar:")) {
       extract(str1, localURL);
     }
     return str1;
   }
 
   private static void extract(String paramString, URL paramURL) throws IOException {
     InputStream localInputStream = paramURL.openStream();
     FileOutputStream localFileOutputStream = new FileOutputStream(paramString);
     byte[] arrayOfByte = new byte[4096];
     int i = 0;
     while ((i = localInputStream.read(arrayOfByte)) > 0) {
       localFileOutputStream.write(arrayOfByte, 0, i);
     }
     localFileOutputStream.close();
     localInputStream.close();
   }
 }

